package com.youpingou.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youpingou.domain.News;
import com.youpingou.service.NewsService;
import com.youpingou.vo.BaseResult;
import com.youpingou.vo.PageRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/news")
public class NewsController {

    @Resource
    private NewsService newsService;

    @GetMapping
    public BaseResult findByPage(PageRequest pageRequest){
        //1 查询
        Page<News> page = this.newsService.findNewsByPage( pageRequest );
        //2 封装
        return BaseResult.ok(page);
    }

}